import http from "@/api";
import { ResPage, SelectTreeOptionResult } from "@/api/interface";
import {
  CreateDepartmentParam,
  DepartmentTreeResult,
  EditDepartmentInfoParam,
  EditDepartmentStatusParam,
  GetDepartmentListParam
} from "@/api/interface/auth/department";

/** 新增部门 */
export const createDepartment = (param: CreateDepartmentParam) => {
  return http.post<string>(`DepartmentManager/CreateDepartment`, param);
};

/** 获取部门树形数据 */
export const getDepartmentTree = () => {
  return http.post<SelectTreeOptionResult[]>(`DepartmentManager/GetDepartmentTree`);
};

/** 获取部门列表 */
export const getDepartmentList = (param: GetDepartmentListParam) => {
  return http.post<ResPage<DepartmentTreeResult>>(`DepartmentManager/GetDepartmentList`, param);
};

/** 修改部门信息 */
export const editDepartmentInfo = (param: EditDepartmentInfoParam) => {
  return http.post<string>(`DepartmentManager/EditDepartmentInfo`, param);
};

/** 修改部门状态 */
export const editDepartmentStatus = (param: EditDepartmentStatusParam) => {
  return http.post<string>(`DepartmentManager/EditDepartmentStatus`, param);
};
